#include"Configuration.h"
#include"DirScanner.h"

#include<iostream>
//目录流
#include <stdio.h>
#include <dirent.h>
#include <sys/stat.h>
DirScanner::DirScanner(){}
vector<string>& DirScanner::getFiles(){}
void DirScanner::traverse(string path){
    DIR * pdir=opendir(path.c_str());
     if (pdir == NULL) {
        perror("opendir");
        return;
    }
    struct dirent* pdirent;
    while((pdirent=readdir(pdir))){
        if(string(pdirent->d_name)!="."&&string(pdirent->d_name)!=".."){
        _files.push_back(string(path).append("/").append(pdirent->d_name));
        }
    }
    closedir(pdir);
    for(auto ele:_files){
        std::cout<<ele<<"\n";
    }
}
DirScanner& DirScanner::operator()(){
    map<string,string> config=Configuration::getInstance()->getConfigMap();
    traverse(config["page_files"]);
}